package com.book.bookprojectapplication.write.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.book.bookprojectapplication.R;
import com.book.bookprojectapplication.write.activity.WriteDecorateActivity;

public class WriteDecoColorFragment  extends Fragment implements OnClickListener{

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {

		View view = inflater.inflate(R.layout.fragmentwritedecocolor, container, false);
		ImageView writecolordeeppink = (ImageView) view.findViewById(R.id.writecolordeeppink);
		ImageView writecolorlawngreen = (ImageView) view.findViewById(R.id.writecolorlawngreen);
		ImageView writecolorred = (ImageView) view.findViewById(R.id.writecolorred);
		ImageView writecolorsteelblue = (ImageView) view.findViewById(R.id.writecolorsteelblue);
		ImageView writecoloraquamarine = (ImageView) view.findViewById(R.id.writecoloraquamarine);
		ImageView writecolorblanchedalmond = (ImageView) view.findViewById(R.id.writecolorblanchedalmond);
		ImageView writecolorgold = (ImageView) view.findViewById(R.id.writecolorgold);	
		
		writecolordeeppink.setOnClickListener(this);
		writecolorlawngreen.setOnClickListener(this);
		writecolorred.setOnClickListener(this);
		writecolorsteelblue.setOnClickListener(this);
		writecoloraquamarine.setOnClickListener(this);
		writecolorblanchedalmond.setOnClickListener(this);
		writecolorgold.setOnClickListener(this);
			
		return view;
	}

	@Override
	public void onClick(View v) {
		switch(v.getId()){
		case R.id.writecolordeeppink:			
			WriteDecorateActivity.setColorEdit(rColorChange(R.color.deeppink));
			System.out.println("deeppink");
			break;
		case R.id.writecolorlawngreen:
			WriteDecorateActivity.setColorEdit(rColorChange(R.color.lawngreen));
			System.out.println("lawngreen");
			break;
		case R.id.writecolorred:
			WriteDecorateActivity.setColorEdit(rColorChange(R.color.red));
			System.out.println("red");
			break;
		case R.id.writecolorsteelblue:
			WriteDecorateActivity.setColorEdit(rColorChange(R.color.steelblue));
			System.out.println("steelblue");
			break;
		case R.id.writecoloraquamarine:
			WriteDecorateActivity.setColorEdit(rColorChange(R.color.aquamarine));
			System.out.println("aquamarine");
			break;
		case R.id.writecolorblanchedalmond:
			WriteDecorateActivity.setColorEdit(rColorChange(R.color.blanchedalmond));
			System.out.println("banchaaa");
			break;
		case R.id.writecolorgold:
			WriteDecorateActivity.setColorEdit(rColorChange(R.color.gold));
			System.out.println("gold");
			break;
		}
				
	}
	
	private int rColorChange(int rColor){
		int color = getResources().getColor(rColor);
		return color;
	}	


}
